<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>华富</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui-pull-refresh.css" />
    <link rel="stylesheet" type="text/css" href="../../css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
</head>
<style>


    /***index_product***/
    .index_product{
      width: 100%;
    }
    .index_product_con{
      width: 100%;
      padding:0.4rem;
    }
    .index_product_list{
      width: 100%;
      background: #fff;
      border-radius: 0.5rem;
      overflow: hidden;
      margin-bottom: 0.4rem;
    }
    .index_product_zi{
      padding: 1.3rem 0.9rem;
    }
    .index_product_zi h5{
      font-size: 1.3rem;
      line-height: 1.2;
      color: #0a0a0a;
      margin-bottom: 1.2rem;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      overflow: hidden;
    }
    .index_product_zi h5 font{
      display: inline-block;
      line-height: 1.5rem;
      font-size: 1rem;
      color: #fff;
      background: #ed6a20;
      border-radius: 0.2rem;
      margin-right: 0.2rem;
      padding: 0 0.4rem;
      vertical-align: top;
    }
    .index_product_zi p{
      font-size: 1.5rem;
      color: #f01818;
      line-height: 1.2;
    }
    .index_product_zi p span{
      float: right;
      line-height: 2rem;
      font-size: 1.1rem;
      color: #666666;
      border: 1px solid #999;
      padding: 0 1rem;
      border-radius: 2rem;
      position: relative;
      top: -0.2rem;
    }
    /***index_product***/


    /***search_wap***/
    .search_wap{
      width: 100%;
      padding-top: 6.5rem;
    }
    .search_wap_con{
      width: 100%;
      padding: 1.5rem 1.3rem;
      background: #fff;
    }

    .index_product_search .index_h5{
      background: #f5f5f5;
    }
    .search_wap_list{
      margin-bottom: 0.9rem;
    }
    .search_wap_list h5{
      font-size: 1.4rem;
      color: #000;
      line-height: 1;
      margin-bottom: 1.5rem;
    }
    .search_wap_list h5 span{
      float: right;
    }
    .search_wap_list h5 span img{
      width: 1.4rem;
    }
    .search_wap_list>span{
      display: inline-block;
      line-height: 3.2rem;
      padding: 0 1.6rem;
      border-radius: 3.2rem;
      background: #f5f5f5;
      font-size: 1.3rem;
      color: #333;
      margin-right: 0.6rem;
      margin-bottom: 0.9rem;
    }

    /***search_wap***/

    .storeAll{padding: 0 1.3rem; padding-top: 6.5rem;}
    .storeLis{background: #fff; box-shadow: 0 0 15px rgba(0, 0, 0, 0.1); margin-top: 1.3rem; padding: 1rem;}
    .storeTop{display: flex; margin: 0 0 1rem;}
    .storeTitle{flex: 1;}
    .storeEnter{align-self: center;}
    .storeTitle h3{font-size: 1.4rem; color: #333;}
    .storeTitle p{font-size: 1.2rem; color: #b9b9b9;}
    .storeAvatar{width: 3.5rem; height: 3.5rem; background-size: cover; border-radius: 4px; overflow: hidden; margin-right: 1rem;}
    .storeEnter .aui-btn{font-size: 1.4rem; color: #ed6a20; border-color: #ed6a20; height: auto; line-height: 2.4rem; padding: 0.05rem 1.1rem; border-radius: 500px;}
    .storeBot ul{display: flex; margin: 0 -0.3rem;}
    .storeBot ul li{flex: 1; padding: 0 0.3rem;}
    .storeBot li img{width: 100%; border-radius: 5px;}
    [v-cloak]:{
      display: none
    }
    .aui-toast-content{
    	color: #fff;
    }
</style>
<body>
<div id="app" style="background: #f5f5f5;" v-cloak>

  <!--search-->
  <div class="search search_search">
    <div class="search_con">
      <div class="search_map" onclick="goBack()"><img src="../../image/back.png"></div>
      <div class="search_input">
        <input type="text" placeholder="搜索" id="keyword" v-model="valueMsg">
        <div class="search_ss"><img src="../../image/search_icon2.png"></div>
        <div class="search_sm"><img src="../../image/search_icon1.png"></div>
      </div>
      <div class="search_info">
        <img src="../../image/search_info.png">
        <span>5</span>
      </div>
    </div>
  </div>
  <!--/search-->


  <div class="aui-refresh-content">

    <div class="storeAll">

      <div class="storeLis" v-for="val in msgList">
        <div class="storeTop">
          <div class="storeAvatar" :style="'background-image:url('+val.store_logo+')'"></div>
          <div class="storeTitle">
            <h3>{{val.store_name}}</h3>
            <p>{{val.collection}}人关注</p>
          </div>
          <div class="storeEnter">
            <a href="javascript:void(0);" class="aui-btn aui-btn-block aui-btn-outlined aui-btn-sm" @click="storeDetail(val.store_id)">进店</a>
          </div>
        </div>
        <div class="storeBot">
          <ul>
            <li v-for="item in val.goods_list"><img :src=item.goods_logo alt=""></li>
          </ul>
        </div>
      </div>



    </div>

  </div>


</div>
</body>
</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/zepto.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/utils.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/aui-tab.js"></script>
<script type="text/javascript" src="../../script/aui-scroll.js"></script>
<script type="text/javascript" src="../../script/aui-pull-refresh.js"></script>
<script type="text/javascript" src="../../script/swiper.min.js"></script>
<script type="text/javascript" src="../../script/aui-toast.js"></script>


<script type="text/javascript">

  apiready = function(){
    var toast = new auiToast({})
    var vm = new Vue({
      el:'#app',
      data:{
        page:1,
        allpage:'',
        msgList:[],
        valueMsg:''
      },
      methods:{
        //跳转
        storeDetail:function(id){
          api.openWin({
              name: 'shop',
              url: '../class/shop.html',
              pageParam: {
                  id:id
              }
          });


        },
        //搜索
        enterKey:function(){
          var _this=this;
          $("#keyword").on('keypress', function(e) {    //#keyword为input文本框
            var keycode = e.keyCode;
            var searchName = $(this).val();
            if(keycode == '13') {
            _this.shopStore($("#keyword").val())
            }
          });
        },
        //店铺展示
        shopStore:function(key){
            var _this = this
            var data={
              token:$api.getStorage('token'),
              keywords:key,
              page:1
            }
            api.ajax({
                url: window.hurl.store_list,
                method: 'post',
                data: {
                    values:data
                }
            },function(ret, err){
                if (ret) {
                    console.log( JSON.stringify( ret ) );
                    if(ret.status==1 || ret.status==0){
                      _this.allpage = ret.all_page;
                      _this.page = ret.page;
                      _this.msgList = ret.list
                      if(ret.list==""){toast.fail({title:'没有商品',duration:1000})}
                    }else{
                      toast.fail({
                        title:ret.info,
                        duration:1000
                      })
                    }
                } else {
                    console.log( JSON.stringify( err) );
                }
            });

        },
        //刷新
        setRefresh:function(){
            var pullRefresh = new auiPullToRefresh({
                container: document.querySelector('.aui-refresh-content'),
                triggerDistance: 100
            }, function(ret) {
                if (ret.status == "success") {
                    setTimeout(function() {
                        pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
                    }, 1500)
                }
            })
        }
      },
      mounted:function(){
        var $_this= this
        this.shopStore()
        this.setRefresh()
        this.enterKey()
        var scroll = new auiScroll({
            listen:true, //是否监听滚动高度，开启后将实时返回滚动高度
            distance:40 //判断到达底部的距离，isToBottom为true
        },function(ret){
            if (ret.isToBottom) {
                $_this.page ++
                if ($_this.page > $_this.allpage) {
                    $_this.page = $_this.allpage
                    return
                }
                api.ajax({
                    url: window.hurl.store_list,
                    method: 'post',
                    data: {
                        values:{
                          token:$api.getStorage('token'),
                          keywords:'',
                          page:$_this.page
                        }
                    },
                    timeout: 300,
                }, function(ret, err) {
                    if (ret) {
                        //  api.alert({ msg: JSON.stringify(ret) });
                        //console.log(JSON.stringify(ret))
                        $_this.msgList = $_this.msgList.concat(ret.list)

                    } else {
                        api.alert({ msg: JSON.stringify(err) });
                    }
                })
            }

        })
      },
      created:function(){

      },
      watch:{
        valueMsg:function(e){
           if(e==""){this.shopStore()}
        }
      }
    })
  }

  function goBack(){
    api.closeWin({

    });
  }



</script>
